package com.hzdesk.media.matvector.koreabatch.client.my_paperless.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;

import com.hzdesk.media.matvector.koreabatch.client.my_paperless.R;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.base.BaseAdapter;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.base.BaseViewHolder;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.bean.DevicesCustomConfigurationBean;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.view_holder.DevicesManagerPagerViewHoder;

/**
 * Created by Administrator on 2018/8/13.
 *
 */

public class DevicesManagerPagerAdapter<T> extends BaseAdapter{

    public DevicesManagerPagerAdapter(Context mContext) {
        super(mContext);
    }

    @Override
    protected int getItemLayout() {
        return R.layout.devices_manager_pager_item;
    }

    @Override
    protected BaseViewHolder getItemViewHolder(View view) {
        return new DevicesManagerPagerViewHoder(view);
    }

    @Override
    protected void onMyBindViewHolder(final BaseViewHolder holder, final int position) {
        final DevicesManagerPagerViewHoder devicesManagerPagerViewHoder= (DevicesManagerPagerViewHoder) holder;
        DevicesCustomConfigurationBean bean = (DevicesCustomConfigurationBean) mlist.get(position);
       String name =  bean.getName();
       int currentUse =  bean.getCurrentUse();
       if(name != null && !TextUtils.isEmpty(name)){
           devicesManagerPagerViewHoder.getTextView_config_name().setText(name);
       }
       if(currentUse == 1){
           devicesManagerPagerViewHoder.getTextView_config_current().setVisibility(View.VISIBLE);
       }else{
           devicesManagerPagerViewHoder.getTextView_config_current().setVisibility(View.GONE);
       }
        devicesManagerPagerViewHoder.getRelativeLayout().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mIonClickedItemListenter.onClickedFist(position);
            }
        });

    }

    @Override
    public int getItemCount() {
        int count = super.getItemCount();
        if(count > 5){
            return count;
        }else{
            return count;
        }
    }
}
